<?php

declare(strict_types=1);

namespace App\Job;

use App\Common\SendMsgUtils;
use Hyperf\AsyncQueue\Job;

class QueueJob extends Job
{
    use SendMsgUtils;

    public $params;

    /**
     * 任务执行失败后的重试次数，即最大执行次数为 $maxAttempts+1 次
     *
     * @var int
     */
    protected $maxAttempts = 2;

    public function __construct($params)
    {
        // 这里最好是普通数据，不要使用携带 IO 的对象，比如 PDO 对象
        $this->params = $params;
    }

    /**
     * 消费进程
     * @return void
     */
    public function handle()
    {
        var_dump('---------------------加好有发送参数----------------------');
        var_dump($this->params);
        $time = date("Y-m-d H:i:s", time());
        var_dump($time);
        $fd = $this->params['fd'];
        $data = $this->params;
        unset($data['fd']);
        unset($data['delay']);
        $this->sendAppAddFriend($fd, $data);
    }
}
